import java.util.Scanner;

/**
 * @author gao
 * @date 2025/8/28 13:28
 */

public class Solution {
    public String complexNumberMultiply(String num1, String num2) {
        // 解析第一个复数
        int[] parts1 = parseComplex(num1);
        int a = parts1[0];
        int b = parts1[1];

        // 解析第二个复数
        int[] parts2 = parseComplex(num2);
        int c = parts2[0];
        int d = parts2[1];

        int realPart = a * c - b * d;// 实部
        int imaginaryPart = a * d + b * c; // 虚部

        return realPart + "+" + imaginaryPart + "i";
    }

    private int[] parseComplex(String num) {
        // 分割实部和虚部
        String[] parts = num.split("\\+");
        int real = Integer.parseInt(parts[0]);
        // 去掉虚部的“i”并转换为整数
        int imaginary = Integer.parseInt(parts[1].substring(0, parts[1].length() - 1));

        return new int[]{real, imaginary};
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String num1 = in.nextLine();
            String num2 = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.complexNumberMultiply(num1, num2));
        }
    }
}